import xadmin
from .models import GoodsCategory, Goods, GoodsImage


class GoodsCategoryAdmin(object):
    list_display = ['name', 'code', 'category_type', 'parent_category']
    list_filter = ['name', 'code', 'category_type', 'parent_category']
    search_field = ['name', 'code', 'category_type', 'parent_category']


class GoodsAdmin(object):
    list_display = ['category', 'name', 'desc', 'price', 'sold_num', 'click_num', 'ship_free', 'goods_front_img']
    list_filter = ['category', 'name', 'desc', 'price', 'sold_num', 'click_num', 'ship_free', 'goods_front_img']
    search_field = ['category', 'name', 'desc', 'price', 'sold_num', 'click_num', 'ship_free', 'goods_front_img']


class GoodsImageAdmin(object):
    list_display = ['goods', 'image']
    list_filter = ['goods', 'image']
    search_field = ['goods', 'image']


xadmin.site.register(GoodsCategory, GoodsCategoryAdmin)
xadmin.site.register(Goods, GoodsAdmin)
xadmin.site.register(GoodsImage, GoodsImageAdmin)
